package com.dmlll.controller;

import com.dmlll.pojo.Spouse;
import com.dmlll.service.SpouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class SpouseController {
    @Autowired
    private SpouseService spouseService;
    @RequestMapping("/inserts")
    @ResponseBody
    public Spouse inserts(Spouse spouse){
        if(spouse.getId()==null) {
            spouseService.inserts(spouse);
        }else {
            spouseService.updateSpouse(spouse);
        }
        return spouse;
    }
    @RequestMapping("/findSpouseById")
    @ResponseBody
    public Spouse findSpouseById(Integer id){
        return spouseService.findSpouseById(id);
    }
}
